/*
This code was generated with the qrsc utility (QRemoteSignal interface
compiler) version R0.0 from file:
qrs.xml

Do not modify this file directly. Modify interface description and
run qrsc once again.
*/
#include "tvservice.h"

#include <QRemoteSignal>

using namespace qrs;

const QString TvService::mName = "Tv";

TvService::TvService ( ServicesManager* parent ): AbsService ( parent ) {
   parent->registerService(this);
}

void TvService::slideshowStarted() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("slideshowStarted");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::slideshowStopped() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("slideshowStopped");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::slideDelayChanged(const int& delay) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("slideDelayChanged");
   msg.setService(mName);
   msg.params().insert("delay",qrs::createArg(delay));

   manager()->send(msg);
}

void TvService::slideAnimChanged(const QString& type) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("slideAnimChanged");
   msg.setService(mName);
   msg.params().insert("type",qrs::createArg(type));

   manager()->send(msg);
}

void TvService::runningLineStarted() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("runningLineStarted");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::runningLineStopped() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("runningLineStopped");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::runningLineTextChanged(const QString& text) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("runningLineTextChanged");
   msg.setService(mName);
   msg.params().insert("text",qrs::createArg(text));

   manager()->send(msg);
}

void TvService::runningLineColorChanged(const QString& color) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("runningLineColorChanged");
   msg.setService(mName);
   msg.params().insert("color",qrs::createArg(color));

   manager()->send(msg);
}

void TvService::runningLineSpeedChanged(const int& speed) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("runningLineSpeedChanged");
   msg.setService(mName);
   msg.params().insert("speed",qrs::createArg(speed));

   manager()->send(msg);
}

void TvService::messageStarted() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("messageStarted");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::messageStopped() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("messageStopped");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::messageTextChanged(const QString& text) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("messageTextChanged");
   msg.setService(mName);
   msg.params().insert("text",qrs::createArg(text));

   manager()->send(msg);
}

void TvService::messageTypeChanged(const QString& type) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("messageTypeChanged");
   msg.setService(mName);
   msg.params().insert("type",qrs::createArg(type));

   manager()->send(msg);
}

void TvService::messageColorChanged(const QString& color) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("messageColorChanged");
   msg.setService(mName);
   msg.params().insert("color",qrs::createArg(color));

   manager()->send(msg);
}

void TvService::videosStarted() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("videosStarted");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::videosStopped() {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("videosStopped");
   msg.setService(mName);

   manager()->send(msg);
}

void TvService::timeScheduleChanged(const int& service, const QString& schedule) {
   if ( manager() == 0 ) {
      return;
   }
   Message msg;
   msg.setMethod("timeScheduleChanged");
   msg.setService(mName);
   msg.params().insert("service",qrs::createArg(service));
   msg.params().insert("schedule",qrs::createArg(schedule));

   manager()->send(msg);
}


void TvService::processMessage (const Message& msg)
      throw(IncorrectMethodException) {
   if ( msg.service() != mName ) {
      throw( IncorrectMethodException(AbsService::tr("Invalid service name: %1").arg(msg.service())) );
   }

   if ( msg.method() == "startSlideshow" ) {
      emit startSlideshow(  );
      return;
   }
   if ( msg.method() == "setSlideDelay" ) {
      int delay;
      if ( ! msg.params().contains("delay") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("delay").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["delay"], delay) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("delay") ) );
      }
      emit setSlideDelay( delay );
      return;
   }
   if ( msg.method() == "setSlideAnim" ) {
      QString type;
      if ( ! msg.params().contains("type") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("type").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["type"], type) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("type") ) );
      }
      emit setSlideAnim( type );
      return;
   }
   if ( msg.method() == "stopSlideshow" ) {
      emit stopSlideshow(  );
      return;
   }
   if ( msg.method() == "startRunningLine" ) {
      emit startRunningLine(  );
      return;
   }
   if ( msg.method() == "setRunningText" ) {
      QString text;
      if ( ! msg.params().contains("text") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("text").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["text"], text) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("text") ) );
      }
      emit setRunningText( text );
      return;
   }
   if ( msg.method() == "setRunningSpeed" ) {
      int speed;
      if ( ! msg.params().contains("speed") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("speed").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["speed"], speed) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("speed") ) );
      }
      emit setRunningSpeed( speed );
      return;
   }
   if ( msg.method() == "setRunningColor" ) {
      QString color;
      if ( ! msg.params().contains("color") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("color").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["color"], color) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("color") ) );
      }
      emit setRunningColor( color );
      return;
   }
   if ( msg.method() == "stopRunningLine" ) {
      emit stopRunningLine(  );
      return;
   }
   if ( msg.method() == "startMessage" ) {
      emit startMessage(  );
      return;
   }
   if ( msg.method() == "stopMessage" ) {
      emit stopMessage(  );
      return;
   }
   if ( msg.method() == "setMessageType" ) {
      QString type;
      if ( ! msg.params().contains("type") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("type").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["type"], type) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("type") ) );
      }
      emit setMessageType( type );
      return;
   }
   if ( msg.method() == "setMessageText" ) {
      QString text;
      if ( ! msg.params().contains("text") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("text").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["text"], text) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("text") ) );
      }
      emit setMessageText( text );
      return;
   }
   if ( msg.method() == "setMessageColor" ) {
      QString color;
      if ( ! msg.params().contains("color") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("color").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["color"], color) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("color") ) );
      }
      emit setMessageColor( color );
      return;
   }
   if ( msg.method() == "startVideos" ) {
      emit startVideos(  );
      return;
   }
   if ( msg.method() == "stopVideos" ) {
      emit stopVideos(  );
      return;
   }
   if ( msg.method() == "setTimeSchedule" ) {
      int service;
      if ( ! msg.params().contains("service") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("service").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["service"], service) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("service") ) );
      }
      QString schedule;
      if ( ! msg.params().contains("schedule") ) {
         throw( IncorrectMethodException( AbsService::tr("Message doesn't contain param \"%1\" required to call method \"%2\"").arg("schedule").arg(msg.method()) ) );
      }
      if ( !qrs::getArgValue(msg.params()["schedule"], schedule) ) {
         throw( IncorrectMethodException( AbsService::tr("Can't obtain \"%1\" param value").arg("schedule") ) );
      }
      emit setTimeSchedule( service, schedule );
      return;
   }
   if ( msg.method() == "sendState" ) {
      emit sendState(  );
      return;
   }

   throw( IncorrectMethodException( AbsService::tr("Unknown method %1").arg(msg.method()) ) );
}
